package cn.edu.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author Mr.ma
 * @since 2022/11/18 15:49
 **/
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket docket(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .groupName("菜鸡小分队")
                .apiInfo(getInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.edu"))
                .paths(PathSelectors.ant("/dept/**"))
                .build();
        return docket;
    }

    private ApiInfo getInfo(){
        Contact DEFAULT_CONTACT = new Contact("五小柳", "http://localhost:8080", "670154833@qq.com");
        ApiInfo Default_ApiInfo = new ApiInfo("SpringBoot整合Swagger2",
                "在SpringBoot（2.5.6）项目中整合Swagger2用于生成API文档，" +
                        "使用swagger-spring-boot-starter（1.9.0.RELEASE）和swagger-bootstrap-ui（1.9.6）",
                "1.0",
                "urn:tos-服务网址条款", DEFAULT_CONTACT,
                "Apache 2.0-开源协议",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
        return Default_ApiInfo;
    }
}
